package org.atovio.servlet.pk2;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * @author AtoVio, Winter Yuan
 */
//@WebFilter("/*")
public class LogFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        // 在过滤器中设置响应编码格式
        servletResponse.setContentType("text/html;charset=utf-8");
        String uri = ((HttpServletRequest) servletRequest).getRequestURI();
        System.out.println("过滤器执行了，uri: " + uri);
        filterChain.doFilter(servletRequest, servletResponse);
    }
}
